﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UsersModuleRights2.aspx.cs"
    Inherits="UsersModuleRights2" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>用户权限设置</title>
    <style>
        .x-grid-row-over .x-grid-cell-inner
        {
            font-weight: bold;
        }
        .x-column-header-inner
        {
            height: 28px;
            background: #E7EBEF url(./images/header.png) repeat-x 0 0;
        }  <style>
        .complete .x-grid-cell-inner {
            text-decoration : line-through;
            color : #777;
        }
        .x-form-check-group
        {
            padding-right:20px;
        }
    </style>
    </style>
    <script>
        var getTasks = function () {
            var msg = "",
                selChildren = App.TreePanel1.getChecked();

            Ext.each(selChildren, function (node) {
                if (msg.length > 0) {
                    msg += ", ";
                }

                msg += node.data.text;
            });

            Ext.Msg.show({
                title: "Completed Tasks",
                msg: msg.length > 0 ? msg : "None",
                icon: Ext.Msg.INFO,
                minWidth: 200,
                buttons: Ext.Msg.OK
            });
        };
        var edit = function (editor, e) {
            /*
            "e" is an edit event with the following properties:

            grid - The grid
            record - The record that was edited
            field - The field name that was edited
            value - The value being set
            originalValue - The original value for the field, before the edit.
            row - The grid table row
            column - The grid Column defining the column that was edited.
            rowIdx - The row index that was edited
            colIdx - The column index that was edited
            */

            // Call DirectMethod
            if (!(e.value === e.originalValue || (Ext.isDate(e.value) && Ext.Date.isEqual(e.value, e.originalValue)))) {
                CompanyX.Edit(e.record.data.mu_id, e.record.data.fid, e.field, e.originalValue, e.value, e.record.data);
            }
        };
        var edit2 = function (editor, e) {

            // Call DirectMethod
            if (!(e.value === e.originalValue || (Ext.isDate(e.value) && Ext.Date.isEqual(e.value, e.originalValue)))) {
                CompanyX.Edit2(e.record.data.lid, e.field, e.originalValue, e.value, e.record.data);
            }
        };
        var rightchange = function (obj) {
            CompanyX.RightChangeSave(App.hf_tree_id.value, App.hf_user_id.value, obj.id, obj.getValue());
            //            if (App.hf_tree_id == "") {
            //                alert("请选择用户");
            //                return;
            //            }
            //            if (App.hf_user_id.value == "") {
            //                alert("靖选择功能模块");
            //                return;
            //            }
            //            obj.items.each(function (item) {
            //                CompanyX.RightChangeSave(App.hf_tree_id.value, App.hf_user_id.value, item.id, item.getValue());
            //            });
            //alert(App.hf_tree_id.value);
            //CompanyX.RightChangeSave();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server">
            <LayoutConfig>
                <ext:HBoxLayoutConfig Align="Stretch" />
            </LayoutConfig>
            <Defaults>
                <ext:Parameter Name="margin" Value="2 0" Mode="Value" />
            </Defaults>
            <Items>
                <ext:GridPanel ID="GridPanel2" runat="server" Title="用户列表" Width="200" CollapseDirection="Left">
                    <TopBar>
                        <ext:Toolbar ID="Toolbar1" runat="server">
                            <Items>
                                <ext:TextField runat="server" ID="txtuser" />
                                <ext:Button ID="Button1" runat="server" Text="查询" UI="Info">
                                    <DirectEvents>
                                        <Click OnEvent="BtnFindUser">
                                            <EventMask ShowMask="true" Msg="加载中...">
                                            </EventMask>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Store>
                        <ext:Store ID="Store2" runat="server" PageSize="20" OnReadData="MyData_Refresh">
                            <Model>
                                <ext:Model ID="Model2" runat="server" IDProperty="用户ID">
                                    <Fields>
                                        <ext:ModelField Name="用户ID" ServerMapping="userid" />
                                        <ext:ModelField Name="用户编号" ServerMapping="usercode" />
                                        <ext:ModelField Name="用户名称" ServerMapping="username" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel>
                        <Columns>
                            <ext:RowNumbererColumn ID="RowNumbererColumn2" runat="server" Width="35" Text="序号" />
                            <ext:Column ID="Column1" runat="server" Text="编号" DataIndex="用户编号" Width="60" />
                            <ext:Column ID="Column5" runat="server" Text="名称" DataIndex="用户名称" />
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel2" runat="server">
                            <DirectEvents>
                                <Select OnEvent="Cell_Click" />
                            </DirectEvents>
                        </ext:RowSelectionModel>
                    </SelectionModel>
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolbar2" runat="server">
                            <Items>
                                <ext:Label ID="Label2" runat="server" Text="每页显示:" />
                                <ext:ToolbarSpacer ID="ToolbarSpacer2" runat="server" Width="10" />
                                <ext:ComboBox ID="ComboBox2" runat="server" Width="80">
                                    <Items>
                                        <ext:ListItem Text="10" />
                                        <ext:ListItem Text="20" />
                                        <ext:ListItem Text="50" />
                                        <ext:ListItem Text="100" />
                                    </Items>
                                    <SelectedItems>
                                        <ext:ListItem Value="20" />
                                    </SelectedItems>
                                    <Listeners>
                                        <Select Handler="#{GridPanel1}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanel1}.store.reload();" />
                                    </Listeners>
                                </ext:ComboBox>
                            </Items>
                            <Plugins>
                                <ext:ProgressBarPager ID="ProgressBarPager2" runat="server" />
                            </Plugins>
                        </ext:PagingToolbar>
                    </BottomBar>
                </ext:GridPanel>
                <ext:BoxSplitter ID="BoxSplitter2" runat="server" Collapsible="true" CollapseTarget="Prev" />
                <ext:TreePanel ID="TreePanel1" runat="server" Title="模块列表" Icon="Accept" CollapseDirection="Left"
                    Height="400" Width="220" UseArrows="true" AutoScroll="true" Animate="true" RootVisible="false">
                    <Root>
                        <ext:Node>
                            <Children>
                                <ext:Node Text="To Do" Icon="Folder">
                                    <Children>
                                        <ext:Node Text="Go jogging" Leaf="true" Checked="False" />
                                        <ext:Node Text="Take a nap" Leaf="true" Checked="False" />
                                        <ext:Node Text="Clean house" Leaf="true" Checked="False" />
                                    </Children>
                                </ext:Node>
                                <ext:Node Text="Grocery List" Icon="Folder">
                                    <Children>
                                        <ext:Node Text="Bananas" Leaf="true" Checked="False" />
                                        <ext:Node Text="Milk" Leaf="true" Checked="False" />
                                        <ext:Node Text="Cereal" Leaf="true" Checked="False" />
                                        <ext:Node Text="Energy foods" Icon="Folder">
                                            <Children>
                                                <ext:Node Text="Coffee" Leaf="true" Checked="False" />
                                                <ext:Node Text="Red Bull" Leaf="true" Checked="False" />
                                            </Children>
                                        </ext:Node>
                                    </Children>
                                </ext:Node>
                                <ext:Node Text="Kitchen Remodel" Icon="Folder">
                                    <Children>
                                        <ext:Node Text="Finish the budget" Leaf="true" Checked="False" />
                                        <ext:Node Text="Call contractors" Leaf="true" Checked="False" />
                                        <ext:Node Text="Choose design" Leaf="true" Checked="False" />
                                    </Children>
                                </ext:Node>
                            </Children>
                        </ext:Node>
                    </Root>
                    <Listeners>
                        <CheckChange Handler="var node = Ext.get(this.getView().getNode(item));
                                      node[checked ? 'addCls' : 'removeCls']('complete')" />
                        <Render Handler="this.getRootNode().expand(true);" Delay="50" />
                    </Listeners>
                    <SelectionModel>
                        <ext:TreeSelectionModel>
                            <DirectEvents>
                                <Select OnEvent="Tree_Row_Click" />
                            </DirectEvents>
                        </ext:TreeSelectionModel>
                    </SelectionModel>
                </ext:TreePanel>
                <ext:BoxSplitter ID="BoxSplitter1" runat="server" Collapsible="true" CollapseTarget="Prev" />
                <ext:TabPanel runat="server" Flex="1">
                    <Items>
                        <ext:GridPanel ID="GridPanel3" runat="server" Title="网格全局设置">
                            <Store>
                                <ext:Store ID="Store3" runat="server" PageSize="50" OnReadData="MyData_Refresh2">
                                    <Model>
                                        <ext:Model ID="Model3" runat="server" IDProperty="lid">
                                            <Fields>
                                                <ext:ModelField Name="lid" ServerMapping="lid" />
                                                <ext:ModelField Name="lindx" ServerMapping="lindx" />
                                                <ext:ModelField Name="fieldname" ServerMapping="fieldname" />
                                                <ext:ModelField Name="fielddisplay" ServerMapping="fielddisplay" />
                                                <ext:ModelField Name="fieldwidth" ServerMapping="fieldwidth" />
                                                <ext:ModelField Name="fieldvisible" ServerMapping="fieldvisible" />
                                                <ext:ModelField Name="gridfoot" ServerMapping="gridfoot" />
                                                <ext:ModelField Name="datatype" ServerMapping="datatype" />
                                                <ext:ModelField Name="showtype" ServerMapping="showtype" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel>
                                <Columns>
                                    <ext:Column ID="Column8" runat="server" Text="序号" DataIndex="lindx" Width="60">
                                        <Editor>
                                            <ext:TextField ID="TextField5" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column ID="Column9" runat="server" Text="字段" DataIndex="fieldname" Width="150">
                                        <Editor>
                                            <ext:TextField ID="TextField6" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column ID="Column10" runat="server" Text="名称" DataIndex="fielddisplay" Width="150">
                                        <Editor>
                                            <ext:TextField ID="TextField7" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column ID="Column11" runat="server" Text="宽度" DataIndex="fieldwidth" Width="100">
                                        <Editor>
                                            <ext:NumberField ID="NumberField1" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column ID="Column13" runat="server" Text="字段类型" DataIndex="datatype" Width="100">
                                        <Editor>
                                            <ext:ComboBox runat="server" ID="ComboBox3">
                                                <Items>
                                                    <ext:ListItem Text="字符" Value="string" />
                                                    <ext:ListItem Text="数字" Value="int" />
                                                    <ext:ListItem Text="小数" Value="float" />
                                                    <ext:ListItem Text="日期" Value="datetime" />
                                                    <ext:ListItem Text="布尔" Value="bool" />
                                                </Items>
                                            </ext:ComboBox>
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column ID="Column12" runat="server" Text="网脚" DataIndex="gridfoot" Width="100">
                                        <Editor>
                                            <ext:ComboBox runat="server" ID="txtgridfoot">
                                                <Items>
                                                    <ext:ListItem Text="汇总" Value="1" />
                                                    <ext:ListItem Text="求和" Value="2" />
                                                    <ext:ListItem Text="平均值" Value="3" />
                                                    <ext:ListItem Text="最大值" Value="4" />
                                                    <ext:ListItem Text="最小值" Value="5" />
                                                </Items>
                                            </ext:ComboBox>
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column ID="Column14" runat="server" Text="显示类型" DataIndex="showtype" Width="100">
                                        <Editor>
                                            <ext:ComboBox runat="server" ID="ComboBox4">
                                                <Items>
                                                    <ext:ListItem Text="常规" Value="0" />
                                                    <ext:ListItem Text="单价" Value="1" />
                                                    <ext:ListItem Text="金额" Value="2" />
                                                    <ext:ListItem Text="数量" Value="3" />
                                                    <ext:ListItem Text="日期" Value="4" />
                                                    <ext:ListItem Text="百分比" Value="5" />
                                                </Items>
                                            </ext:ComboBox>
                                        </Editor>
                                    </ext:Column>
                                    <ext:CheckColumn ID="CheckColumn1" runat="server" Text="可视" DataIndex="fieldvisible"
                                        Width="100" Editable="true">
                                    </ext:CheckColumn>
                                </Columns>
                            </ColumnModel>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel3" runat="server" Mode="Multi" />
                            </SelectionModel>
                            <Plugins>
                                <ext:CellEditing ID="CellEditing2" runat="server" ClicksToEdit="1">
                                    <Listeners>
                                        <Edit Fn="edit2" />
                                    </Listeners>
                                </ext:CellEditing>
                            </Plugins>
                            <Buttons>
                              <ext:Button ID="Button4" runat="server" Text="设置所有用户" UI="Info">
                                    <DirectEvents>
                                        <Click OnEvent="BatchVisb_Click" />
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="Button3" runat="server" Text="删除字段" UI="Danger">
                                    <DirectEvents>
                                        <Click OnEvent="BatchDel2_Click" />
                                    </DirectEvents>
                                </ext:Button>
                            </Buttons>
                        </ext:GridPanel>
                        <ext:GridPanel ID="GridPanel1" runat="server" Title="网格字段权限设置" TitleAlign="Center">
                            <TopBar>
                                <ext:Toolbar ID="Toolbar2" runat="server">
                                    <Items>
                                        <ext:CheckboxGroup ID="CheckboxGroup1" runat="server">
                                            <Items>
                                                <ext:Checkbox ID="M_Browse" runat="server" FieldLabel="浏览">
                                                    <Listeners>
                                                        <Change Fn="rightchange">
                                                        </Change>
                                                    </Listeners>
                                                </ext:Checkbox>
                                                <ext:Checkbox ID="M_Export" runat="server" FieldLabel="导出">
                                                    <Listeners>
                                                        <Change Fn="rightchange">
                                                        </Change>
                                                    </Listeners>
                                                </ext:Checkbox>
                                            </Items>
                                        </ext:CheckboxGroup>
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
                            <Store>
                                <ext:Store ID="Store1" runat="server" PageSize="50" OnReadData="MyData_Refresh2">
                                    <Model>
                                        <ext:Model ID="Model1" runat="server" IDProperty="mu_id">
                                            <Fields>
                                                <ext:ModelField Name="mu_id" ServerMapping="mu_id" />
                                                <ext:ModelField Name="fid" ServerMapping="fid" />
                                                <ext:ModelField Name="lindx" ServerMapping="lindx" />
                                                <ext:ModelField Name="fieldname" ServerMapping="fieldname" />
                                                <ext:ModelField Name="fielddisplay" ServerMapping="fielddisplay" />
                                                <ext:ModelField Name="fieldwidth" ServerMapping="fieldwidth" />
                                                <ext:ModelField Name="mu_visible" ServerMapping="mu_visible" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel>
                                <Columns>
                                    <ext:Column ID="Column2" runat="server" Text="序号" DataIndex="lindx" Width="60">
                                        <Editor>
                                            <ext:TextField ID="TextField2" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column ID="Column3" runat="server" Text="字段" DataIndex="fieldname" Width="150">
                                        <Editor>
                                            <ext:TextField ID="TextField1" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column ID="Column4" runat="server" Text="名称" DataIndex="fielddisplay" Width="150">
                                        <Editor>
                                            <ext:TextField ID="TextField3" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column ID="Column6" runat="server" Text="宽度" DataIndex="fieldwidth" Width="150">
                                        <Editor>
                                            <ext:NumberField ID="TextField4" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:CheckColumn ID="Column7" runat="server" Text="可视" DataIndex="mu_visible" Width="150"
                                        Editable="true">
                                    </ext:CheckColumn>
                                </Columns>
                            </ColumnModel>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Multi" />
                            </SelectionModel>
                            <Plugins>
                                <ext:CellEditing ID="CellEditing1" runat="server">
                                    <Listeners>
                                        <Edit Fn="edit" />
                                    </Listeners>
                                </ext:CellEditing>
                            </Plugins>
                            <BottomBar>
                                <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                                    <Items>
                                        <ext:Label ID="Label1" runat="server" Text="每页显示:" />
                                        <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                        <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                            <Items>
                                                <ext:ListItem Text="10" />
                                                <ext:ListItem Text="20" />
                                                <ext:ListItem Text="50" />
                                                <ext:ListItem Text="100" />
                                            </Items>
                                            <SelectedItems>
                                                <ext:ListItem Value="50" />
                                            </SelectedItems>
                                            <Listeners>
                                                <Select Handler="#{GridPanel1}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanel1}.store.reload();" />
                                            </Listeners>
                                        </ext:ComboBox>
                                    </Items>
                                    <Plugins>
                                        <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                                    </Plugins>
                                </ext:PagingToolbar>
                            </BottomBar>
                            <Buttons>
                                <ext:Button ID="Button2" runat="server" Text="删除字段" UI="Info">
                                    <DirectEvents>
                                        <Click OnEvent="BatchDel_Click" />
                                    </DirectEvents>
                                </ext:Button>
                            </Buttons>
                        </ext:GridPanel>
                    </Items>
                </ext:TabPanel>
                <ext:Hidden ID="hf_user_id" runat="server" ClientIDMode="Static" />
                <ext:Hidden ID="hf_tree_id" runat="server" ClientIDMode="Static" />
            </Items>
        </ext:Viewport>
    </div>
    </form>
</body>
</html>
